package com.cosc716.restaurant.commands.Tables;

import java.util.ArrayList;
import java.util.Iterator;

import com.cosc716.restaurant.commands.Command;
import com.cosc716.restaurant.domain.Table;
import com.cosc716.restaurant.domain.collections.Tables;
import com.cosc716.restaurant.system.Aggregator;

public class CommandGetOrderedTables implements Command {
	
	@Override
	public Object execute(Aggregator aggregator) {
		Tables tables = aggregator.getTables();
		ArrayList<Table> orderedTables = new ArrayList<Table>();
		
		Iterator i = tables.getOrderedTableIterator();
		while (i.hasNext()) {
			Table table = (Table) i.next();
			orderedTables.add(table);
		}
		
		return orderedTables;
	}
	
}
